package com.etc.controller;

import com.etc.entity.CommentResult;
import com.etc.entity.Owner;
import com.etc.service.OwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OwnerController {
    @Autowired
    private OwnerService ownerService;

    @RequestMapping("owner/insert")
    public CommentResult insert(@RequestBody Owner owner)
    {
        int result = ownerService.insert(owner);
        if (result>0){
            int id = ownerService.findByName(owner.getName()).getId();
            return new CommentResult(200,"success",id);
        }
        return new CommentResult(444,"failed");
    }


}
